<?php
session_start();
if(!isset($_SESSION['uid']))
 	{?>
		<script type="text/javascript">
			window.location="error.php";
		</script>
	<?php
 	}else
 		{
			include_once 'topStaticBar.php';
			include_once 'dataBaseConnectivityFile.php';
			$sql_get=mysql_query("select * from stock where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
                	$STOCK_ID=$db_field["STOCK_ID"];
                	$TITLE=$db_field["TITLE"];
                    $CONDITION=$db_field["CONDITION"];                    
                    $MAKE=$db_field["MAKE"];
                    $BODY_STYLE=$db_field["BODY_STYLE"];
                    $START_YEAR=$db_field["START_YEAR"];
					$END_YEAR=$db_field["END_YEAR"];
					$MILEAGE=$db_field["MILEAGE"];
					$TRANSMISSION=$db_field["TRANSMISSION"];
					$DRIVE_TRAIN=$db_field["DRIVE_TRAIN"];
					$EXTERIOR_COLOR=$db_field["EXTERIOR_COLOR"];
					$INTERIOR_COLOR=$db_field["INTERIOR_COLOR"];
					$FUEL_TYPE=$db_field["FUEL_TYPE"];
					$CITY_MILES_PER_GALLON=$db_field["CITY_MILES_PER_GALLON"];
					$HIGHWAY_MILES_PER_GALLON=$db_field["HIGHWAY_MILES_PER_GALLON"];            
                    $get_status=$db_field["STATUS"];
                    $PRICE=$db_field["PRICE"];
                    $CONTACT_NO=$db_field["CONTACT_NO"];
                    $IMAGE_PATH=$db_field["IMAGE_PATH"];
                    $ENGINE=$db_field["ENGINE"];
                    $MODEL_NUMBER=$db_field["MODEL_NUMBER"];
                    $VIN=$db_field["VIN"];                    
                }	
			?>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<h1 align="center">Complete Vehicle Information</h1>
<hr></hr>
<div id="basictable">
<table align="center" border="1">
	<tr>
		<td>
			<a href="deleteStock.php?stock_id=<?php echo $_REQUEST['stock_id']?>">Delete this Vehicle? Click here</a>
		</td>
	</tr>
</table>
<hr></hr>
<table align="center" border="1">
    <th align="center"><h2 align="center" style="color: gray;width: 200px">Vehicle Image</h2></th>	
	<th align="center"><h2>Delete</h2></th>	
	<tr>
		<td>
			<a href="<?php echo $IMAGE_PATH?>"><img src="<?php echo $IMAGE_PATH?>" width="200px" height="100px"></img></a>
		</td>
		<td align="center">
			<a href="deleteImage.php?stock_id=<?php echo $STOCK_ID ?>">Delete</a>
		</td>				
	</tr>
</table>
<hr></hr>
<table align="center" border="1">

    <th align="center"><h2 align="center" style="color: gray;width: 200px">Basic Information</h2></th>
    <th align="center"><a href="editBasicInformation.php?stock_id=<?php echo $STOCK_ID ?>">Edit Basic Information</a></th>	

		<tr align="right">
			<td>
				Title:
			</td>
			<td align="left">
				<?php echo $TITLE;?>
			</td>
		</tr>
		
		<tr align="right">
			<td>
				Engine:
			</td>
			<td align="left">
				<?php echo $ENGINE;?>
			</td>
		</tr>
	
		<tr align="right">
			<td>
				Model Number:
			</td>
			<td align="left">
				<?php echo $MODEL_NUMBER;?>
			</td>
		</tr>		
				
		<tr align="right">
			<td>
				Condition:
			</td>
			<td align="left">
				<?php echo $CONDITION;?>
			</td>
		</tr>

		<tr align="right">
			<td>
				Make:
			</td>
			<td align="left">
				<?php echo $MAKE;?>
			</td>
		</tr>

		<tr align="right">
			<td>
				Body Style:
			</td>
			<td align="left">
				<?php echo $BODY_STYLE;?>
			</td>
		</tr>

		<tr align="right">
			<td>
				Start Year:
			</td>
			<td align="left">
				<?php echo $START_YEAR;?>
			</td>
		</tr>

		<tr align="right">
			<td>
				End Year:
			</td>
			<td align="left">
				<?php echo $END_YEAR;?>
			</td>
		</tr>

		<tr align="right">
			<td>
				Odometer:
			</td>
			<td align="left">
				<?php echo $MILEAGE;?>
			</td>
		</tr>

		<tr align="right">
			<td>
				Transmission:
			</td>
			<td align="left">
				<?php echo $TRANSMISSION;?>
			</td>
		</tr>			

		<tr align="right">
			<td>
				Drive Train:
			</td>
			<td align="left">
				<?php echo $DRIVE_TRAIN;?>
			</td>
		</tr>

		<tr align="right">
			<td>
				Exterior Color:
			</td>
			<td align="left" style="background-color: <?php echo $EXTERIOR_COLOR?>">
				<?php echo $EXTERIOR_COLOR;?>
			</td>
		</tr>

		<tr align="right">
			<td>
				Interior Color:
			</td>
			<td align="left" style="background-color: <?php echo $INTERIOR_COLOR?>">
				<?php echo $INTERIOR_COLOR;?>
			</td>
		</tr>		

		<tr align="right">
			<td>
				Fuel Type:
			</td>
			<td align="left">
				<?php echo $FUEL_TYPE;?>
			</td>
		</tr>		

		<tr align="right">
			<td>
				City Miles/Gallon:
			</td>
			<td align="left">
				<?php echo $CITY_MILES_PER_GALLON;?>
			</td>
		</tr>		

		<tr align="right">
			<td>
				Highway Miles/Gallon:
			</td>
			<td align="left">
				<?php echo $HIGHWAY_MILES_PER_GALLON;?>
			</td>
		</tr>	

		<tr align="right">
			<td>
				Status:
			</td>
			<td align="left">
				<?php echo $get_status;?>
			</td>
		</tr>	

		<tr align="right">
			<td>
				Price($):
			</td>
			<td align="left">
				<?php echo $PRICE;?>
			</td>
		</tr>			

		<tr align="right">
			<td>
				Contact #:
			</td>
			<td align="left">
				<?php echo $CONTACT_NO;?>
			</td>
		</tr>
		
		<tr align="right">
			<td>
				VIN #:
			</td>
			<td align="left">
				<?php echo $VIN;?>
			</td>
		</tr>						
	</table>
<?php 
 		}
?>
<hr></hr>

<!--  Overview Details	---->
	<table align="center" border="1" style="overflow: hidden;">
      <th><h2 align="center" style="color: gray;">Overview Information</h2></th>
      <th><h2 align="center" style="color: gray;">Edit</h2></th>
      <th><h2 align="center" style="color: gray;">Delete</h2></th>
<?php 
		$sql_get=mysql_query("select * from overview where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
 					$OVERVIEW_ID=$db_field["OVERVIEW_ID"];
 					$VEHICLE_OVERVIEW=$db_field["VEHICLE_OVERVIEW"];               	
                
                ?>
           <tr>     
				<td align="left">
					<?php echo $VEHICLE_OVERVIEW;?>
				</td>
				<td align="center">
					<a href="editOverviewInformation.php?overview_id=<?php echo $OVERVIEW_ID ?>">Edit</a>
				</td>
				<td align="center">
					<a href="deleteOverviewInformation.php?overview_id=<?php echo $OVERVIEW_ID ?>">Delete</a>
				</td>			
			</tr>
<?php
     }
 ?>	
 	</table>	

<hr></hr> 
 
<!--Mechanical Information -->

	<table  align="center" border="1" style="overflow: hidden;">
      <th><h2 align="center" style="color: gray;">Mechanic Information</h2></th>
      <th><h2 align="center" style="color: gray;">Edit</h2></th>
      <th><h2 align="center" style="color: gray;">Delete</h2></th>
 <?php 
		$sql_get=mysql_query("select * from mechanics where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
 					$MECHANIC_ID=$db_field["MECHANICS_ID"];
 					$MECHANICAL=$db_field["MECHANICAL"];               	
                
                ?>
           <tr>     
				<td align="left">
					<li><?php echo $MECHANICAL;?></li>
				</td>
				<td align="center">
					<a href="editMechanicInformation.php?mechanic_id=<?php echo $MECHANIC_ID ?>">Edit</a>
				</td>
				<td align="center">
					<a href="deleteMechanicInformation.php?mechanic_id=<?php echo $MECHANIC_ID ?>">Delete</a>
				</td>			
			</tr>
<?php
     }
 ?>	
 	</table>	
 <hr></hr>
 
<!-- Exterior -->
	
	<table align="center" border="1" style="overflow: hidden;">
      <th><h2 align="center" style="color: gray;">Exterior Information</h2></th>
      <th><h2 align="center" style="color: gray;">Edit</h2></th>
      <th><h2 align="center" style="color: gray;">Delete</h2></th>
 <?php 
$sql_get=mysql_query("select * from exterior where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
 					$EXTERIOR_ID=$db_field["EXTERIOR_ID"];
 					$EXTERIOR=$db_field["EXTERIOR"];               	
                
                ?>
           <tr>     
				<td align="left">
					<li><?php echo $EXTERIOR;?></li>
				</td>
				<td align="center">
					<a href="editExteriorInformation.php?exterior_id=<?php echo $EXTERIOR_ID ?>">Edit</a>
				</td>
				<td align="center">
					<a href="deleteExteriorInformation.php?exterior_id=<?php echo $EXTERIOR_ID ?>">Delete</a>
				</td>			
			</tr>
<?php
     }
 ?>	
 	</table>	
 <hr></hr>
 
 <!-- Interior -->

<table align="center" border="1" style="overflow: hidden;">
    <th><h2 align="center" style="color: gray;">Interior Information</h2></th>
      <th><h2 align="center" style="color: gray;">Edit</h2></th>
      <th><h2 align="center" style="color: gray;">Delete</h2></th>
 <?php 
		$sql_get=mysql_query("select * from interior where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
 					$INTERIOR_ID=$db_field["INTERIOR_ID"];
 					$INTERIOR=$db_field["INTERIOR"];               	
                
                ?>
           <tr>     
				<td align="left">
					<li><?php echo $INTERIOR;?></li>
				</td>
				<td align="center">
					<a href="editInteriorInformation.php?interior_id=<?php echo $INTERIOR_ID ?>">Edit</a>
				</td>
				<td align="center">
					<a href="deleteInteriorInformation.php?interior_id=<?php echo $INTERIOR_ID ?>">Delete</a>
				</td>			
			</tr>
<?php
     }
 ?>	
 	</table>	
 
 <hr></hr>
 
 
 <!-- Fuel -->
 
<table align="center" border="1" style="overflow: hidden;">
    <th><h2 align="center" style="color: gray;">EPA Fuel Information</h2></th>
      <th><h2 align="center" style="color: gray;">Edit</h2></th>
      <th><h2 align="center" style="color: gray;">Delete</h2></th>
 <?php 
		$sql_get=mysql_query("select * from fuel_specification where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
 					$FUEL_SPECIFICATION_ID=$db_field["FUEL_SPECIFICATION_ID"];
 					$FUEL_SPECIFICATION_DESCRIPTION=$db_field["FUEL_SPECIFICATION_DESCRIPTION"];               	
                
                ?>
           <tr>     
				<td align="left">
					<li><?php echo $FUEL_SPECIFICATION_DESCRIPTION;?></li>
				</td>
				<td align="center">
					<a href="editFuelInformation.php?fuel_id=<?php echo $FUEL_SPECIFICATION_ID ?>">Edit</a>
				</td>
				<td align="center">
					<a href="deleteFuelInformation.php?fuel_id=<?php echo $FUEL_SPECIFICATION_ID ?>">Delete</a>
				</td>			
			</tr>
<?php
     }
 ?>	
 	</table>	
 <hr></hr>
 
 
  <!-- Safety -->

<table align="center" border="1" style="overflow: hidden;">
    <th><h2 align="center" style="color: gray;">Safety Information</h2></th>
      <th><h2 align="center" style="color: gray;">Edit</h2></th>
      <th><h2 align="center" style="color: gray;">Delete</h2></th>
 <?php 
		$sql_get=mysql_query("select * from safety where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
 					$SAFETY_ID=$db_field["SAFETY_ID"];
 					$SAFETY_DESCRIPTION=$db_field["SAFETY_DESCRIPTION"];
                ?>
           <tr>     
				<td align="left">
					<li><?php echo $SAFETY_DESCRIPTION;?></li>
				</td>
				<td align="center">
					<a href="editSafetyInformation.php?safety_id=<?php echo $SAFETY_ID ?>">Edit</a>
				</td>
				<td align="center">
					<a href="deleteSafetyInformation.php?safety_id=<?php echo $SAFETY_ID ?>">Delete</a>
				</td>			
			</tr>
<?php
     }
 ?>	
 	</table>	
 <hr></hr>
   <!-- Additional Feature -->

<table align="center" border="1" style="overflow: hidden;">
    <th><h2 align="center" style="color: gray;">Additional Feature Information</h2></th>
      <th><h2 align="center" style="color: gray;">Edit</h2></th>
      <th><h2 align="center" style="color: gray;">Delete</h2></th>     
 <?php
		$sql_get=mysql_query("select * from additional_features where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
 					$ADDITIONAL_FEATURE_ID=$db_field["ADDITIONAL_FEATURE_ID"];
 					$ADDITIONAL_FEATURE_DESCRIPTION=$db_field["ADDITIONAL_FEATURE_DESCRIPTION"];
                ?>
           <tr>     
				<td align="left">
					<?php echo $ADDITIONAL_FEATURE_DESCRIPTION;?>
				</td>
				<td align="center">
					<a href="editAdditionalFeatureInformation.php?add_id=<?php echo $ADDITIONAL_FEATURE_ID ?>">Edit</a>
				</td>
				<td align="center">
					<a href="deleteAddtionalFeatureInformation.php?add_id=<?php echo $ADDITIONAL_FEATURE_ID ?>">Delete</a>
				</td>			
			</tr>
<?php
     }
 ?>	
 	</table>
 	
<hr></hr> 	
    <!-- Vehicle COndition -->

<table align="center" border="1" style="overflow: hidden;">
    <h2 align="center" style="color: gray;">Vehicle Condition Information</h2>
      <th><h2 align="center" style="color: gray;">Service History</h2></th>
      <th><h2 align="center" style="color: gray;">Condition Report</h2></th>
      <th><h2 align="center" style="color: gray;">Tires & Wheels</h2></th>            
      <th><h2 align="center" style="color: gray;">Edit</h2></th>
      <th><h2 align="center" style="color: gray;">Delete</h2></th>     
 <?php
		$sql_get=mysql_query("select * from vehicle_condition where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
 					$VEHICLE_CONDITION_ID=$db_field["VEHICLE_CONDITION_ID"];
 					$SERVICE_HISTORY=$db_field["SERVICE_HISTORY"];
 					$CONDITION_REPORT=$db_field["CONDITION_REPORT"];
 					$TIRES_WHEELS=$db_field["TIRES_WHEELS"];
                ?>
           <tr>     
				<td align="left">
					<?php echo $SERVICE_HISTORY;?>
				</td>
				<td align="left">
					<li><?php echo $CONDITION_REPORT;?></li>
				</td>
				<td align="left">
					<li><?php echo $TIRES_WHEELS;?></li>
				</td>								
				<td align="center">
					<a href="editVehicleCondition.php?condition_id=<?php echo $VEHICLE_CONDITION_ID ?>">Edit</a>
				</td>
				<td align="center">
					<a href="deleteVehicleCondition.php?condition_id=<?php echo $VEHICLE_CONDITION_ID ?>">Delete</a>
				</td>			
			</tr>
<?php
     }
 ?>	
 	</table>
<hr></hr>
<form name="list_images" enctype="multipart/form-data" method="post" action="listImageServer.php">
<h2 align="center" style="color: gray;">Add List for Car Images</h2>
<input name="stock_id" type="hidden" value="<?php echo $_REQUEST['stock_id'] ?>">
<table align="center" border="1" style="overflow: hidden;">
      <tr align="center">
      	<td align="center">
      		<input type="file" name="image">		
      	</td>
      	<td>
      		<input type="submit" name="submit" value="Upload">
      	</td>
      </tr>
</table>
</form> 	
<?php
	$query="select * from vehicle_image where STOCK_ID=".$_REQUEST['stock_id']." order by VEHICLE_IMAGE_ID asc";
	$result=mysql_query($query);
 
	$cols=2;
	echo "<table align=center border=0>";
	do{
		
		echo "<tr>";
		for($i=1;$i<=$cols;$i++)
		{
			$row=mysql_fetch_array($result);
			if($row){
				$img = $row['PATH'];
				$VEHICLE_IMAGE_ID=$row['VEHICLE_IMAGE_ID'];
 ?>
        <td>
            <table align="center">
                <tr valign="top">
                    <td><a href="<?php echo $img?>"><img width="400px" height="100px" src="<?php echo $img?>" /></a></td>
					<td><a href="deleteListImage.php?vehicleImageId=<?php echo $VEHICLE_IMAGE_ID ?>&stock_id=<?php echo $_REQUEST['stock_id'] ?>">Delete</a></td>
                </tr>
                <td width="50">&nbsp;</td>
           </table>
        </td>
<?php
			}
			else{
				echo "<td>&nbsp;</td>";
			}
		}
	} while($row);
	echo "</table>";
 ?>
<hr></hr> 		
</div>
 